//
//  SCVideoListTableViewCell.m
//  OurMoon
//
//  Created by dllo on 15/11/3.
//  Copyright © 2015年 sc. All rights reserved.
//

#import "SCVideoListTableViewCell.h"
#import "NightHeader.h"
#import "UIImageView+WebCache.h"
#import "FitHeader.h"
@implementation SCVideoListTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createViews];
    }
    return self;
}
- (void)createViews
{
    _titleLabel = [[UILabel alloc] init];
    [_titleLabel NightWithType:UIViewColorTypeNormal];
    [self.contentView addSubview:_titleLabel];
    
    
    _descriptionLabel = [[UILabel alloc] init];
    _descriptionLabel.font = [UIFont systemFontOfSize:15 * FitWidth];
    [_descriptionLabel NightWithType:UIViewColorTypeNormal];
    [self.contentView addSubview:_descriptionLabel];
    
    _bigImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:_bigImageView];
    _playImageView = [[UIImageView alloc] initWithFrame:CGRectMake(140 * FitWidth, 70 * FitHeight, 64 * FitWidth, 64 * FitHeight)];
    _playImageView.image = [UIImage imageNamed:@"bofanganniu"];
    [_bigImageView addSubview:_playImageView];
    
    _lengthLabel = [[UILabel alloc] init];
    _lengthLabel.font = [UIFont systemFontOfSize:13 * FitWidth];
    _lengthLabel.backgroundColor = [UIColor grayColor];
    [_lengthLabel NightWithType:UIViewColorTypeNormal];
    [self.contentView addSubview:_lengthLabel];
    
    _replyCountLable = [[UILabel alloc] init];
    _replyCountLable.font = [UIFont systemFontOfSize:13 * FitWidth];
    _replyCountLable.backgroundColor = [UIColor darkGrayColor];
    [_replyCountLable NightWithType:UIViewColorTypeNormal];
    [self.contentView addSubview:_replyCountLable];
    
    _playCountLabel = [[UILabel alloc] init];
    _playCountLabel.font = [UIFont systemFontOfSize:13 * FitWidth];
    _playCountLabel.backgroundColor = [UIColor darkGrayColor];
    [_playCountLabel NightWithType:UIViewColorTypeNormal];
    [self.contentView addSubview:_playCountLabel];
}
- (void)setVideoListModel:(VideoListModel *)videoListModel
{
    _titleLabel.text = videoListModel.title;
    _descriptionLabel.text = videoListModel.descriptioned;
    [_bigImageView sd_setImageWithURL:[NSURL URLWithString:videoListModel.cover] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    _lengthLabel.text = [NSString stringWithFormat:@"时长:%ld", videoListModel.length];
    _replyCountLable.text = [NSString stringWithFormat:@"评论:%ld", videoListModel.replyCount];
    _playCountLabel.text = [NSString stringWithFormat:@"播放:%ld", videoListModel.playCount];
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    _titleLabel.frame = CGRectMake(10 * FitWidth, 10 * FitHeight, self.contentView.frame.size.width - 20 * FitWidth, 40 * FitHeight);
    _descriptionLabel.frame = CGRectMake(_titleLabel.frame.origin.x, _titleLabel.frame.origin.y + _titleLabel.frame.size.height, _titleLabel.frame.size.width, 30 * FitHeight);
    _bigImageView.frame = CGRectMake(_descriptionLabel.frame.origin.x, _descriptionLabel.frame.origin.y + _descriptionLabel.frame.size.height, _descriptionLabel.frame.size.width, 180 * FitHeight);
    _lengthLabel.frame = CGRectMake(_bigImageView.frame.origin.x, _bigImageView.frame.origin.y + _bigImageView.frame.size.height + 5 * FitHeight, 100 * FitWidth, 25 * FitHeight);
    _playCountLabel.frame = CGRectMake(_lengthLabel.frame.origin.x + _lengthLabel.frame.size.width + 5 * FitWidth, _lengthLabel.frame.origin.y, _lengthLabel.frame.size.width, _lengthLabel.frame.size.height);
    _replyCountLable.frame = CGRectMake(_playCountLabel.frame.origin.x + _playCountLabel.frame.size.width + 30 * FitWidth, _playCountLabel.frame.origin.y, _playCountLabel.frame.size.width, _playCountLabel.frame.size.height);
}

@end
